<?php
function add_user($username, $password, $age, $gender, $type)
    {
    include 'open_db.php';

    // insert user query
    $query = "INSERT INTO $dbtable (UserName, UserPass, UserAge, UserGender, UserType) VALUES ('$username', PASSWORD('$password'), '$age', '$gender', '$type')";

    // send the query
    if ($result = $mysqli->query($query))
        {
	echo 'successfuly added user: '.$username;	
	}
    else
	{
	echo 'error adding user '.$username.' to database. DB error: '.$mysqli->error;
	}

    $query = "FLUSH PRIVILEGES";
    if (($result = $mysqli->query($query)) == FALSE)
	{
	echo 'Error, insert query failed';
	}

    include 'close_db.php';
    }
?>
